@extends('layouts.app')

@section('content')

    <el-input placeholder="请输入关键字"
              v-model="form.keywords">
        <i slot="suffix" class="el-input__icon el-icon-search" @click="getCommunityList"></i>
    </el-input>

    <el-table :data="table.list">
        <el-table-column label="序号" type="index" width="50"></el-table-column>
        <el-table-column label="小区名称" prop="name" width="150">
            <template slot-scope="scope">
                <el-link type="primary" :href="'/community/detail?id=' + scope.row.id">@{{ scope.row.name }}</el-link>
            </template>
        </el-table-column>
        <el-table-column label="地址" prop="address"></el-table-column>
        <el-table-column label="操作" width="80">
            <template slot-scope="scope">
                <el-row>
                    <el-button size="mini" type="primary" @click="communityEdit(scope.row)">编辑</el-button>
                </el-row>
                <el-row>
                    <el-button size="mini" type="danger" @click="communityDel(scope.row)">删除</el-button>
                </el-row>
            </template>
        </el-table-column>
    </el-table>

    <el-pagination
            @current-change="handleCurrentChange"
            :current-page.sync="form.current_page"
            :page-size="form.page_size"
            layout="total, prev, pager, next"
            :total="form.total">
    </el-pagination>

    <el-dialog
            :title="dialog.title"
            :visible.sync="dialog.isShow"
            width="90%">
        <el-form label-width="60px">
            <el-form-item label="名称">
                <el-input v-model="communityDetail.name"></el-input>
            </el-form-item>
            <el-form-item label="地址">
                <el-input v-model="communityDetail.address"></el-input>
            </el-form-item>
            <el-form-item label="描述">
                <el-input type="textarea" :rows="3" v-model="communityDetail.description"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" :rows="3" v-model="communityDetail.remarks"></el-input>
            </el-form-item>
            <el-form-item label="图纸">
                <el-upload
                        name="file"
                        :data="{_token: '{{csrf_token()}}'}"
                        action="/community/upload"
                        :on-success="fileSuccess"
                        :on-preview="filePreview"
                        :on-remove="fileRemove"
                        :file-list="communityDetail.thumb"
                        :limit="1"
                        :on-exceed="fileExceed"
                        list-type="picture">
                    <el-button size="small" type="primary">点击上传</el-button>
                    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2M</div>
                </el-upload>
            </el-form-item>
        </el-form>
        <el-row style="text-align:center;">
            <el-button type="primary" @click="communitySave" :disabled="dialog.disabled">保存</el-button>
        </el-row>
    </el-dialog>

    <el-button type="primary"
               @click="communityAdd"
               class="fix-button">新增</el-button>
@endsection

@section('js')
    <script src="/js/community/index.js"></script>
@endsection